package com.yang.action;

import com.yang.entity.Orderdetail;
import com.yang.service.OrderdetailService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;

@WebServlet("/saveOrderdetail")
public class OrderdetailSaveAction extends HttpServlet {
    OrderdetailService orderdetailService = new OrderdetailService();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Orderdetail orderdetail = new Orderdetail();
        String productname = req.getParameter("productname");
        orderdetail.setProductname(productname);
        String productcrice = req.getParameter("productcrice");
        String productcount = req.getParameter("productcount");
        orderdetail.setProductcount(Integer.parseInt(productcount));
        String orderid = req.getParameter("orderid");
        orderdetail.setOrderid(orderid);
        String productid = req.getParameter("productid");
        orderdetail.setProductid(Integer.parseInt(productid));
        int num = orderdetailService.saveOrderdetail(orderdetail);
        resp.setContentType("text/text;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(num);
        out.flush();
        out.close();
    }
}

